package com.hyk.commonLib.common.utils;

import com.hwangjr.rxbus.Bus;

/**
 * Created by 贺玉琨 on 2019/3/21.
 */
public class BusUtils {
    private static Bus sBus;

    protected static synchronized Bus getBus() {
        if (sBus == null) {
            synchronized (BusUtils.class) {
                if (sBus == null) {
                    sBus = new Bus();
                }
            }
        }
        return sBus;
    }

    public static void init() {

    }

    public static void postEvent(String tag) {
        sBus.post(tag, new Object());
    }

    public static void postEvent(String tag, Object event) {
        sBus.post(tag, event);
    }

    public static void register(Object object) {
        getBus().register(object);
    }

    public static void unregister(Object object) {
        getBus().unregister(object);
    }
}
